'use strict'
const path = require('path')

function resolve(dir) {
	return path.join(__dirname, dir)
}

const webpack = require('webpack');

// 引入等比适配插件
const px2rem = require('postcss-px2rem')

// 配置基本大小
const postcss = px2rem({
	// 基准大小 baseSize，需要和rem.js中相同
	remUnit: 16
})

const name = process.env.VUE_APP_TITLE || '' // page title
const port = process.env.port || 8080;

module.exports = {
	publicPath: '/static/helph5/', // process.env.NODE_ENV === 'production' ? '/dist/' : '/',
	outputDir: 'dist',
	assetsDir: 'static',
	lintOnSave: process.env.NODE_ENV === 'development',
	productionSourceMap: false,
	devServer: {
		port: port,
		open: true,
		disableHostCheck: true,
		overlay: {
			warnings: false,
			errors: false
		},
		proxy: {
			'/api': {
				target: "https://wechat.accortech.cn",
				ws: true,
				changeOrigin: true,
				pathRewrite: {
					'^/api': ''
				}
			}
		}
	},
	css: {
		loaderOptions: {
			sass: {
				sassOptions: {
			 	outputStyle: 'expanded'
				}
			},
			postcss: {
				plugins: [
					postcss
				]
			}
		}
	},
	configureWebpack: {
		// provide the app's title in webpack's name field, so that
		// it can be accessed in index.html to inject the correct title.
		name: name,
		resolve: {
			alias: {
				'@': resolve('src')
			}
		}
	},
	configureWebpack: config => {
		config.plugins.push(new webpack.ProvidePlugin({
			$: "jquery",
			jQuery: "jquery",
			"windows.jQuery": "jquery"
		}));

		config.externals = {
			"$": "jquery",
			jQuery: "jquery",
		};
	},
}
